package org.jeecg.modules.charge.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.entity.charge.ChargeFeeitem;
import org.jeecg.modules.charge.entity.ChargeFeeitemTree;
import org.jeecg.modules.charge.mapper.ChargeFeeitemMapper;
import org.jeecg.modules.charge.service.IChargeFeeitemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 收费项目
 * @Author: jeecg-boot
 * @Date:   2019-07-04
 * @Version: V1.0
 */
@Service
public class ChargeFeeitemServiceImpl extends ServiceImpl<ChargeFeeitemMapper, ChargeFeeitem> implements IChargeFeeitemService {

    @Autowired
    private ChargeFeeitemMapper chargeFeeitemMapper;

     @Override
    public Map<String,List<String>> queryFeeproject(){
        List<String> listCategory = chargeFeeitemMapper.selectCategory();
        Map<String,List<String>>  feeProject = new HashMap<>();
        for(int i=0;i<listCategory.size();i++){
           String category = listCategory.get(i);
           List<String> feeValue = chargeFeeitemMapper.queryFeeproject(category);
           feeProject.put(category,feeValue);
        }
        return  feeProject;
    }

    @Override
   public  List<Map> selectFee(){
        return  chargeFeeitemMapper.selectFee();
   }

    @Override
    public List<ChargeFeeitemTree> getCategory() {
        return  chargeFeeitemMapper.getCategory();
    }

    @Override
    public Page<ChargeFeeitem> listByParams(Page<ChargeFeeitem> page, Map map) {
        return page.setRecords(chargeFeeitemMapper.listByParams(page,map));
    }

    public List<ChargeFeeitem> selectFeeItemList(){
        List<ChargeFeeitem>  list   = chargeFeeitemMapper.selectFeeItemList();
        return  list;
    }

    @Override
    public ChargeFeeitem getFeeitemByCode(String feeCode) {
        return chargeFeeitemMapper.getByCode(feeCode);
    }

    @Override
    public ChargeFeeitem getFeeitemById(String id) {
        return chargeFeeitemMapper.getFeeitemById(id);
    }

    @Override
    public List<ChargeFeeitem> queryItemByName(String itemName) {
        return chargeFeeitemMapper.queryItemByName(itemName);
    }

    @Override
    public Integer getChargeFeeRule(String id) {
        return chargeFeeitemMapper.getChargeFeeRule(id);
    }
}
